<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>申报审核-主任</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .btn{
        text-align: right;
    }
    .layui-table-cell .layui-form-checkbox[lay-skin=primary]{
        top: 4px!important;
    }
</style>
<body>
<div>
    <div class="item">
        <img src="../img/chengguo.png" alt="" style="margin: 0 5px 0 20px;"> <span
            style="font-size: 22px;display: inline-block;vertical-align: middle;">申报审核(主任)</span>
    </div>
    <hr class="layui-bg-blue">
    <%--<form class="layui-form" action="">--%>
        <div class="layui-form" style="margin-left: 12px">
            <%--<div class="layui-input-block">--%>
                <input type="radio" name="status" lay-filter="status" checked value="0" title="未审核">
                <input type="radio" lay-filter="status" value="1" name="status" title="通过">
                <input type="radio" lay-filter="status" value="2" name="status" title="退回">
                <input type="radio" lay-filter="status" value="3" name="status" title="不通过">

            <%--</div>--%>
        </div>
    <%--</form>--%>

    <script type="text/html" id="toolbar1">
        <div class="layui-btn-container">

            <button type="button" class="layui-btn add layui-btn-sm" lay-event="pass" id="approval" style="" >
                <i class="layui-icon layui-icon-ok"></i>
                通过
            </button>
            <button type="button" class="layui-btn add layui-btn-sm" lay-event="nopass" id="back" style="" >
                <i class="layui-icon layui-icon-close"></i>
                退回
            </button>
            <button type="button" class="layui-btn add layui-btn-sm" lay-event="npass" id="disapproval" style="" >
                <i class="layui-icon layui-icon-close"></i>
                不通过
            </button>
            <button type="button" class="layui-btn immp layui-btn-sm " id="del" style="margin-right: 15px"onclick="export1();" >
                <i class="layui-icon layui-icon-export"></i>
                导出
            </button>
        </div>

    </script>
    <div>
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</div>
</body>
<script type="text/html" id="barDemo">
    {{#  if(d.sDirectorLeaderStatus == 0){ }}
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="look">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">审核</a>
    {{#  }else{ }}
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="look">查看</a>
    {{#  } }}
</script>
<script type="text/html" id="xuhao">
    {{d.LAY_TABLE_INDEX+1}}
</script>
<script>
    var status1=0;
    layui.use(['table','layer','laydate'], function(){
        var table = layui.table
            ,layer=layui.layer
            ,form=layui.form
            ,laydate=layui.laydate
        var master=table.render({
            elem: '#test'
            , url: '/rpmTopic/getUserPermissionList'//数据接口
            ,where:{
                status:0
            }
            ,toolbar:toolbar1
            ,cols: [[
                {type:'checkbox'},
                {field:'sex', title: '序号',templet: '#xuhao'}
                ,{field:'planName', title: '计划名称', align: 'center'}
                ,{field:'deptName', title: '科室', align: 'center'} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                ,{field:'userName', title: '姓名', align: 'center'}
                ,{field:'filingTime', title: '备案时间', align: 'center'}
                ,{field:'teacheerOpinion', title: '退回意见', align: 'center'}
                , {field: 'type', title: '审核', toolbar: '#barDemo'}
            ]],
            page:true
        });
        form.on('radio(status)', function (data) {
            master.reload({
                where: {
                    status: data.value
                }
            })
            if(data.value == "0" || data.value == 0){
                status1=0;
                $("#approval").css("display","");
                $("#disapproval").css("display","");
                $("#back").css("display","");

            }
            if(data.value == "1" || data.value == 1){
                status1=1;
                $("#approval").css("display","none");
                $("#disapproval").css("display","none");
                $("#back").css("display","none");

            }
            if(data.value == "2" || data.value == 2){
                status1=2;
                $("#approval").css("display","none");
                $("#disapproval").css("display","none");
                $("#back").css("display","none");

            }
            if(data.value == "3" || data.value == 3){
                status1=3;
                $("#approval").css("display","none");
                $("#disapproval").css("display","none");
                $("#back").css("display","none");

            }
        });
        form.render();

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                window.location.href='/rpmPlan/auditdirector?type=0&btype=edit&userId='+data.userId+'&planId='+data.planId+'&trId='+data.trId;
            }else {
                window.location.href='/rpmPlan/auditdirector?type=0&btype=look&userId='+data.userId+'&planId='+data.planId
            }
        });

        table.on('toolbar(test)',function (obj) {
            var data = table.checkStatus('test').data;
            console.log(data)
            // var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'pass':
                    if (data.length == 0 || data.length < 0) {
                        layer.msg("请选择一条或者多条进行提交。");
                        return false;
                    } else if (data.length > 0) {
                        var topicId = "";
                        var sDirectorLeaderStatus ="";
                        for (var i = 0; i < data.length; i++) {
                            topicId += data[i].topicId + ",";
                            // sDirectorLeaderStatus="1";
                        }
                        $.ajax({
                            type: "post",
                            url: "/rpmTopic/updateBatch",
                            dataType: "json",
                            data: {
                                topicId: topicId,
                                sDirectorLeaderStatus: 2
                            },
                            success: function (res) {
                                if (res.code == 0) {
                                    layer.msg(res.msg);
                                    master.reload();
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                    }
                    break;
                case 'nopass':
                    if (data.length == 0 || data.length < 0) {
                        layer.msg("请选择一条或者多条进行提交。");
                        return false;
                    } else if (data.length > 0) {
                        var topicId = "";
                        var sDirectorLeaderStatus ="";
                        for (var i = 0; i < data.length; i++) {
                            topicId += data[i].topicId + ",";
                        }
                        layer.open({
                            type: 1,
                            title:'退回意见',
                            btn: ['确定', '取消'],
                            shade: 0.5,
                            maxmin: true, //开启最大化最小化按钮
                            area: ['30%', '40%'],
                            content: '<div id="cont" style="margin: 10px">\n' +
                                '        <form class="layui-form" action="" id="ajaxforms" lay-filter="ajaxforms">\n' +
                                '            <div class="layui-form-item">\n' +
                                '                <div class="layui-inline">\n' +
                                '                    <div class="layui-form-item layui-form-text">\n' +
                                '                        <label class="layui-form-label">退回意见:</label>\n' +
                                '                        <div class="layui-input-inline">\n' +
                                '                            <textarea placeholder="请输入内容" id="areatext" class="layui-textarea"  name="teacheerOpinion"></textarea>\n' +
                                '                        </div>\n' +
                                '                    </div>\n' +
                                '                </div>\n' +
                                '            </div>\n' +
                                '        </form>\n' +
                                '    </div>',
                            yes:function (index) {
                                    $.ajax({
                                    type: "post",
                                    url: "/rpmTopic/updateBatch",
                                    dataType: "json",
                                    data: {
                                        sDirectorLeaderOpinion: $('#areatext').val(),
                                        topicId: topicId,
                                        sDirectorLeaderStatus: 3
                                    },
                                    success: function (res) {
                                        if (res.code == 0) {
                                            layer.msg('操作成功！', {icon: 1});
                                            layer.closeAll();
                                        } else {
                                            layer.msg(res.msg);
                                        }
                                        master.reload();
                                    }
                                })
                            }
                        })
                    }
                    break;
                case 'npass':
                    if (data.length == 0 || data.length < 0) {
                        layer.msg("请选择一条或者多条进行提交。");
                        return false;
                    } else if (data.length > 0) {
                        var topicId = "";
                        var sDirectorLeaderStatus ="";
                        for (var i = 0; i < data.length; i++) {
                            topicId += data[i].topicId + ",";
                        }
                        $.ajax({
                            type: "post",
                            url: "/rpmTopic/updateBatch",
                            dataType: "json",
                            data: {
                                topicId: topicId,
                                sDirectorLeaderStatus: 4
                            },
                            success: function (res) {
                                if (res.code == 0) {
                                    layer.msg(res.msg);
                                    master.reload();
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                    }
                    break;
            }

        })

    })


    function export1(){
        window.location.href = '/rpmTopic/examineExport?status='+status1
    }
</script>
</html>

</body>
</html>

